/**
 * Created by IntelliJ IDEA.
 * User: alexander
 * Date: 08.09.11
 * Time: 18:56
 * To change this template use File | Settings | File Templates.
 */

/*
	TODO:
		1. First page and buttons
		2. Suitable colors done
		3. lifebar not proper done

		--------------------
		4. Towers evolution
		5. Enemies evolution
 */
package com.etc {
import com.etc.buttons.ButtonBase;

import flash.display.Graphics;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;


public class Test extends Sprite {

	private var _head: MovieClip = null;

	public function Test() {

		var button:CustomSimpleButton = new CustomSimpleButton( 100, 45, "Game");
		button.x = 100;
		button.y = 100;
		addChild(button);


	}
}
}

import flash.display.Shape;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;


class CustomSimpleButton extends SimpleButton {

    public function CustomSimpleButton( w: Number, h: Number, text:String ) {
        upState      = new ButtonDisplayState(w,h,text,0x433a34,0x345aa0);
		overState      = new ButtonDisplayState(w,h,text,0xffffff,0x345aa0);
        downState        = new ButtonDisplayState(w,h,text,0x433a34,0xd39dd4);
        hitTestState   = new ButtonDisplayState(w,h,text,0xa279a2,0xd39dd4);
        hitTestState.x = 0;
        hitTestState.y = 0;
        useHandCursor  = true;
    }
}

class ButtonDisplayState extends Sprite {
    private var bgColor:uint, tColor: uint;
	private var w: uint, h: uint;
	private var text: String;

    public function ButtonDisplayState(  w: uint, h: uint, text: String, tcolor: uint, bgColor:uint ) {
        this.bgColor = bgColor;
		this.tColor = tcolor;
		this.w = w;
		this.h = h;
		this.text = text;
        draw();
    }

    private function draw():void {

        graphics.beginFill(bgColor);
        graphics.drawRoundRect(-w/2 , -h/2 , w , h , 25, 25);
        graphics.endFill();

		var tf: TextField  = new TextField();
		var format:TextFormat = new TextFormat();
		format.font = "Arial";
		format.size = 16;
		format.bold = true;
		format.underline = false;
		format.align = TextFormatAlign.CENTER;
		format.color = tColor;
		tf.defaultTextFormat = format;
		tf.width = w;
		tf.height = h;
		tf.x = -w/2;
		tf.y = -10;
		addChild( tf );
		tf.text = text;
    }
}